<%--
  Created by IntelliJ IDEA.
  User: Murphy
  Date: 2017/12/17
  Time: 12:59
  To change this template use File | Settings | File Templates.
--%>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@ include file="/jsp/base/taglib.jsp" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <base href="<%=basePath%>">
  <title></title>

  <%@include file="/jsp/base/javascript.jsp"%>
  <%@include file="/jsp/base/style.jsp"%>
  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
    <script type="text/javascript">

        $(function(){
            $("#level").click(function(){
                if($(this).val() == '1'){
                    $.ajax({
                        url:'/Menu/loadMenuList',
                        type:'post',
                        date:{},
                        dataType:'json',
                        success:function(msg){
                            if(msg.length >0){
                                $('#parentId').removeAttr("disabled");
                            }
                            var html = "";
                            for(var i = 0;i<msg.length;i++){
                                html += "<option value=\""+msg[i].id+"\">"+msg[i].name+"</option>";
                            }
                            $("#parentId").html(html);
                        }
                    });
                }else {
                    $("#parentId").html("");
                    $('#parentId').attr("disabled","disabled");
                };
            });
            $("#saveBtn").click(function(){
                // 将表单复制到父画面，在父页面的回调函数里提交表单
                var popupForm= $(parent.document.body).children("div[id='popupFormDiv']").append($("#popupForm"));
                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index);
            });
            $("#default").click(function(){
                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index);
            });
        });


    </script>
  <style type="text/css">
    .content-wrapper{
      margin-left: 0;
    }
  </style>


</head>
<body class="hold-transition skin-blue sidebar-mini">
  <div class="content-wrapper">
    <!-- Main content -->
    <section class="content">
      <div class="row">

        <div class="col-md-6">
          <!-- Horizontal Form -->
          <div class="box box-info">
            <%--<div class="box-header with-border">--%>
              <%--<h3 class="box-title">Horizontal Form</h3>--%>
            <%--</div>--%>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal" id="popupForm" action="/Menu/save" method="post">
              <div class="box-body">

                <div class="form-group">
                  <label for="level" class="col-sm-2 control-label">栏目等级</label>
                  <div class="col-sm-10">
                    <select class="form-control" id="level" name="level">
                        <option value="0">顶级栏目</option>
                        <option value="1">一级栏目</option>
                    </select>
                  </div>
                </div>

                  <div class="form-group">
                      <label for="parentId" class="col-sm-2 control-label">上级栏目</label>
                      <div class="col-sm-10">
                          <select class="form-control" disabled id="parentId" name="parentId">
                              <!-- 上级栏目-->
                          </select>
                      </div>
                  </div>

                <div class="form-group">
                  <label for="inputName" class="col-sm-2 control-label">名称</label>

                  <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputName" name="name" placeholder="Name">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputHrefUrl" class="col-sm-2 control-label">地址</label>

                  <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputHrefUrl" name="hrefUrl" placeholder="HrefUrl">
                  </div>
                </div>
                  <div class="form-group">
                      <label for="remark" class="col-sm-2 control-label">描述</label>

                      <div class="col-sm-10">
                          <textarea class="form-control" rows="3" placeholder="Enter ..." id="remark" name="remark"></textarea>
                      </div>
                  </div>


              </div>
              <!-- /.box-body -->
              <div class="box-footer">
                <button type="submit" class="btn btn-default" id="default">取消</button>
                <button type="submit" class="btn btn-info pull-right" id="saveBtn">提交</button>
              </div>
              <!-- /.box-footer -->
            </form>
          </div>
          <!-- /.box -->
          <!-- general form elements disabled -->

        </div>
        <!--/.col (right) -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->
  </div>

</body>
</html>
